interface Item {
  name: string;
}


class DataManager<T extends Item> {
  constructor(private data:T[]){

  }
  getItem(index:number):string{
    return this.data[index].name;
  }
}

const data = new DataManager([
  {
    name:'dell'
  }
])
data.getItem(0)


interface Test{
  name:string
}
class DataManager2<T extends Item> {
  constructor(private data:T[]){

  }
  getItem(index:number):T{
    return this.data[index];
  }
}

const data2 = new DataManager2<Test>([
  {
    name:'dell'
  }
])

class DataManager3<T extends number | string> {
  constructor(private data:T[]){

  }
  getItem(index:number):T{
    return this.data[index];
  }
}

const data3 = new DataManager3<string>([
  
])

// const func:<T> () => string = <T>() => {
//   return '123'
// }

// 如何使用泛型作为一个具体的类型注解
function hello<T>(params: T) {
  return params
}

const func:<T>(params:T) => T = hello;